/**
 * IServiceTask.java $version 1.0 2010. 08. 12
 *
 * Copyright 2010 NHN Corp. All rights Reserved.
 * NHN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */
package com.eltonkent.dashboard.service;

import java.util.concurrent.Callable;

/**
 * 
 * A cancellable asynchronous computation. This class provides a base
 * implementation of Callable, with methods to start and cancel a computation,
 * query to see if the computation is complete, and retrieve the result of the
 * computation. The result can only be retrieved when the computation has
 * completed;
 * 
 * A task that returns a result and may throw an exception. Implementors define
 * a single method with no arguments called call.
 * 
 * 
 * @author Accenture India
 */
public interface IServiceTask<T> extends Callable<T> {

	/**
	 * Attempts to cancel execution of this task. If this attempt will
	 * successful, and this task has not started when cancel is called, this
	 * task should never run.
	 */
	void cancel();

	/**
	 * Runs on the Service thread after {@link super#call()}. The specified
	 * result is the value returned by {@link super#call()} or null if the task
	 * was cancelled or an exception occured.
	 * 
	 * @param result
	 *            The result of the operation computed by
	 * 
	 * @see #onPreExecute()
	 * @see super{@link #call()}
	 */
	void postExecute(T t, Throwable throwable);

	/**
	 * Runs on the Service thread before {@link super#call()}.
	 * 
	 * @see #onPostExecute(Object)
	 * @see super{@link #call()}
	 */
	void preExecute() throws Exception;
}
